<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="text" indent="no"  />
		<xsl:template match="/">
&lt;cfcomponent displayname="<xsl:value-of select="//bean/@name"/>" output="false"&gt;
		<xsl:for-each select="root/bean/dbtable/column">&lt;cfproperty name="<xsl:value-of select="@name" />" type="<xsl:value-of select="@type" />" default="" /&gt;
		</xsl:for-each>
	&lt;!---
	PROPERTIES
	---&gt;
	&lt;cfset variables.instance = StructNew() /&gt;

	&lt;!---
	INITIALIZATION / CONFIGURATION
	---&gt;
	&lt;cffunction name="_getTO" access="public" returntype="any" output="false"&gt;
		&lt;cfreturn variables.instance /&gt;
 	&lt;/cffunction&gt;


	&lt;cffunction name="init" access="public" returntype="any" _returntype="<xsl:value-of select="//bean/@path"/>" output="false"&gt;
		<xsl:for-each select="root/bean/dbtable/column">&lt;cfargument name="<xsl:value-of select="@name" />" _type="<xsl:value-of select="@type" />" required="false" default="" /&gt;
		</xsl:for-each>
		&lt;!--- run setters ---&gt;
		<xsl:for-each select="root/bean/dbtable/column">&lt;cfset set<xsl:value-of select="@name" />(arguments.<xsl:value-of select="@name" />) /&gt;
		</xsl:for-each>

		&lt;cfreturn this /&gt;
 	&lt;/cffunction&gt;

	&lt;!---
	ACCESSORS
	---&gt;<xsl:for-each select="root/bean/dbtable/column">

<xsl:choose>
<xsl:when test="@hibernateClass='org.hibernate.mapping.ManyToOne'">
	&lt;cffunction name="set<xsl:value-of select="@name" />" access="public" returntype="void" output="false"&gt;
		&lt;cfargument name="<xsl:value-of select="@name" />" _type="<xsl:value-of select="@type" />" _columntype="<xsl:value-of select="@columnType" />" _hibernateclass="<xsl:value-of select="@hibernateClass" />" required="true" /&gt;
		&lt;cfscript&gt;
		if(NOT isStruct(arguments.<xsl:value-of select="@name" />)) {
			variables.instance.<xsl:value-of select="@name" /> = createObject("java", "java.util.HashSet").init();
		} else {
			variables.instance.<xsl:value-of select="@name" /> = arguments.<xsl:value-of select="@name" />;
		}
		&lt;/cfscript&gt;
	&lt;/cffunction&gt;</xsl:when>
<xsl:when test="substring(@type,1,13)='java.util.Set'">
	&lt;cffunction name="set<xsl:value-of select="@name" />" access="public" returntype="void" output="false"&gt;
		&lt;cfargument name="<xsl:value-of select="@name" />" _type="<xsl:value-of select="@type" />" _columntype="<xsl:value-of select="@columnType" />" _hibernateclass="<xsl:value-of select="@hibernateClass" />" required="true" /&gt;
		&lt;cfscript&gt;
		if(NOT isStruct(arguments.<xsl:value-of select="@name" />)) {
			variables.instance.<xsl:value-of select="@name" /> = createObject("java", "java.util.HashSet").init();
		} else {
			variables.instance.<xsl:value-of select="@name" /> = arguments.<xsl:value-of select="@name" />;
		}
		&lt;/cfscript&gt;
	&lt;/cffunction&gt;</xsl:when>
<xsl:otherwise>
	&lt;cffunction name="set<xsl:value-of select="@name" />" access="public" returntype="void" output="false"&gt;
		&lt;cfargument name="<xsl:value-of select="@name" />" _type="<xsl:value-of select="@type" />" _columntype="<xsl:value-of select="@columnType" />" _hibernateclass="<xsl:value-of select="@hibernateClass" />" required="true" /&gt;
		&lt;cfset variables.instance.<xsl:value-of select="@name" /> = arguments.<xsl:value-of select="@name" /> /&gt;
	&lt;/cffunction&gt;</xsl:otherwise></xsl:choose>
	&lt;cffunction name="get<xsl:value-of select="@name" />" access="public" _returntype="<xsl:value-of select="@type" />" returntype="any" output="false"&gt;
		&lt;cfreturn variables.instance.<xsl:value-of select="@name" /> /&gt;
	&lt;/cffunction&gt;
</xsl:for-each>

	&lt;!---
	PUBLIC FUNCTIONS
	---&gt;
	<!-- custom code -->


&lt;/cfcomponent&gt;</xsl:template>
</xsl:stylesheet>